package com.linlong.linlongchat.controller;


import com.linlong.linlongchat.domain.po.Result;
import com.linlong.linlongchat.service.IRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 华少
 * @since 2024-09-20
 */
@RestController
@RequestMapping("/record")
@Api(tags = "会话记录接口")
public class RecordController {

    @Autowired
    private IRecordService recordService;

    @GetMapping("/getRecordByAccount/{userAccount}")
    @ApiOperation("根据用户账号查询会话")
    public Result<List<String>> getRecordByAccount(@PathVariable("userAccount") String userAccount){
        return recordService.getRecordByAccount(userAccount);
    }

    @PostMapping("/addRecord")
    @ApiOperation("添加会话记录")
    public Result addRecord(@RequestBody String friendAccount){
        return recordService.addRecord(friendAccount);
    }

    @PutMapping("/updateTime/{userAccount}")
    @ApiOperation("更新会话时间")
    public Result updateTime(@PathVariable("userAccount") String userAccount, @RequestBody String friendAccount){
        return recordService.updateTime(userAccount,friendAccount);
    }

    @PutMapping("/upDeleteStatus")
    @ApiOperation("更新会话状态 0默认 1删除")
    public Result upDeleteStatus(@PathVariable("userAccount") String userAccount, @RequestBody String friendAccount){
        return recordService.upDeleteStatus(userAccount,friendAccount);
    }

}
